const {verify} = require('jsonwebtoken');
const Router = require('koa-router');

const momentRouter = new Router({prefix: '/moment'});

const {
  create,
  detail,
  list,
  update,
  remove,
  addLabels,
  fileInfo
} = require('../controller/moment.controller.js');
const {
  verifyAuth,
  verifyPermission
} = require('../middleware/anth.middleware');
const {
  verifyLabelsExists
} = require('../middleware/label.middleware')

momentRouter.post('/', verifyAuth, create);
momentRouter.get('/', list)
momentRouter.get('/:momentId', detail)
momentRouter.patch('/:momentId', verifyAuth, verifyPermission,update)
momentRouter.delete('/:momentId', verifyAuth, verifyPermission,remove)
momentRouter.post('/:momentId/labels', verifyAuth, verifyPermission,verifyLabelsExists,addLabels)

momentRouter.get('/images/:filename',fileInfo)

module.exports = momentRouter;
